package com.quan.xczs.rpc.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import tk.mybatis.mapper.entity.Condition;

import com.quan.base.common.base.service.support.BaseService;
import com.quan.xczs.rpc.api.XczsGoodsGroupGoodsService;
import com.quan.xczs.rpc.dao.mapper.XczsGoodsGroupGoodsMapper;
import com.quan.xczs.rpc.model.XczsGoodsGroupGoods;

@Service
public class XczsGoodsGroupGoodsServiceImpl extends BaseService<XczsGoodsGroupGoods, Integer> implements XczsGoodsGroupGoodsService {
	
	@Autowired
	private XczsGoodsGroupGoodsMapper mapper ;

	@Override
	public void addGoodsGroupGoods(Integer goodsGroupId, List<Integer> goodsIds) {
		for (Integer goodsId : goodsIds) {
			XczsGoodsGroupGoods entity = new XczsGoodsGroupGoods() ;
			entity.setGoodsGroupId(goodsGroupId);
			entity.setGoodsId(goodsId);
			super.insertSelective(entity);
		}
	}

	@Override
	public void deleteByGoodsGroupId(Integer goodsGroupId) {
		Condition condition = new Condition(XczsGoodsGroupGoods.class) ;
		condition.createCriteria().andEqualTo("goodsGroupId", goodsGroupId);
		this.mapper.deleteByCondition(condition) ;
	}

	@Override
	public List<XczsGoodsGroupGoods> selectGoods(Integer goodsGroupId) {
		return this.mapper.selectGoods(goodsGroupId);
	}
	
}
